#include "ctrl_hw.h"
#include "hwclass/hw_motor_class.h"

Ctrl_hw* Ctrl_hw::handler = nullptr;
static HW_Motor_Class *motorclass = nullptr;
static int ctrlmode = 0;

Ctrl_hw::Ctrl_hw(QObject *parent)
    : QObject{parent}
{
    motorclass = HW_Motor_Class::getHandler();
}

Ctrl_hw::~Ctrl_hw()
{

}

void Ctrl_hw::invokable_setMode(int mode)
{
    ctrlmode = mode;
    emit sig_ctrlmode(mode);
    motorclass->set_motor_speed(0);
}

void Ctrl_hw::invokable_setSpeed(int value)
{
    if(ctrlmode > 0)
    {
        value = value * 3;
        motorclass->set_motor_speed(value);
    }
    else
    {
        value = value/5;
        motorclass->set_motor_speed(value);
    }

}
